ActionController::Routing::Routes.draw do |map|
  # The priority is based upon order of creation: first created -> highest priority.
  
  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up '' 
  # -- just remember to delete public/index.html.
  
  # Root index
  map.connect '', :controller => "welcome"
  map.connect '/u', :controller => 'welcome'
  
  # Naming Routes
  
  map.welcome 'welcome',
              :controller => 'welcome'
  
  map.admin '/u/:screen_name/admin', 
            :controller =>'admin/dashboard', 
            :action => 'index'
  
  map.login 'login', 
            :controller => 'sign', 
            :action => 'sign_in'
            
  map.sign_out 'signout', 
               :controller => 'sign', 
               :action => 'sign_out'
  
  map.index '/u/:screen_name',
            :controller => 'entries',
            :action => 'index'
            
  map.register 'register',
               :controller => 'register'
  
  map.rss 'u/:screen_name/rss',
          :controller => 'xml',
          :action => 'rss'
          
  map.entry_show 'u/:screen_name/entries/:id',
                 :controller => 'entries',
                 :action => 'show',
                 :id => /\d+/
          
  map.with_options(:controller => 'entries', :action => 'index') do |entries|
    entries.connect 'u/:screen_name/page/:page', :page => /\d+/
    entries.connect 'u/:screen_name', :page => 1
  end
          
  %w{entries}.each do |i|
    map.connect "u/:screen_name/#{i}", :controller => "#{i}", :action => 'index'
    map.connect "u/:screen_name/#{i}/:action", :controller => "#{i}"
    map.connect "u/:screen_name/#{i}/:action/:id", :controller => "#[i}", :id => /\d+/
  end

  # Install the default route as the lowest priority.
  map.connect 'u/:screen_name/:controller/:action/:id.:format'
  map.connect 'u/:screen_name/:controller/:action/:id'
  
  map.connect 'password/recover/:token', :controller => 'password', :action => 'recover_password'
  
  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
end
